//
//  UIImageView-WebImage.swift
//  ZLWeibo
//
//  Created by zhanglongtao on 16/12/28.
//  Copyright © 2016年 hanju001. All rights reserved.
//

import Foundation

import SDWebImage

extension UIImageView{
    
    //隔离SBWebImage的方法
    func hm_setImage(urlString: String?, placeholder: UIImage?, isAvatar: Bool = false) {
        
        
        guard let urlString = urlString,
            let url = URL(string: urlString) else{
            
            image = placeholder
            return
            
        }
        sd_setImage(with: url, placeholderImage: placeholder, options: [], progress: nil) { (image, _, _, _) in
            
            //完成会调用  是否使图像 设置圆角
            if isAvatar {
                
                self.image = image?.hm_avaterImage(size: self.bounds.size)
            }
            
        }
        
    }
    
}
